#include "display.h"

char disp = 0;

void DispDigit(char *pDigit)
{
	switch (*pDigit)
   {
		case 0: display_digit_0();
				break;
		case 1: display_digit_1();
				break;
		case 2: display_digit_2();
				break;
		case 3: display_digit_3();
				break;
		case 4: display_digit_4();
				break;
		case 5: display_digit_5();
				break;
		case 6: display_digit_6();
				break;
		case 7: display_digit_7();
				break;
		case 8: display_digit_8();
				break;
		case 9: display_digit_9();
				break;
		case 10: display_digit_none();
				break;
   }
}

void DispOneCharOnePos(char *pChar, char pPos)
{
	if (*pChar!=99)
	{
		DispDigit(pChar);
		switch (pPos)
		{
			case 0:	chooseLED1();
					break;
			case 1:	chooseLED2();
					break;
			case 2:	chooseLED3();
					break;
			case 3:	chooseLED4();
					break;
		}
	}
}

void DispOneNum(int *pInt)
{
	char temp1 = 0;
	n[0] = *pInt/1000;
	n[1] = (*pInt%1000)/100;
	n[2] = (*pInt%100)/10;
	n[3] = (*pInt%10);
	while ((n[temp1]==0)&&(temp1<3))
	{
		n[temp1] = 99;
		temp1++;
	}
}

void DispTwoNum(int *pInt1, int *pInt2)
{
	int temp;
	temp = (int) ((*pInt1 * 100)+ *pInt2);
	DispOneNum(&temp);
}

void blink_enable(void)
{
	static unsigned int count_i, count_j;
	if (count_i<=1000)	count_i++;
	else
	{
		count_i = 0;
		if (count_j<=100)	count_j++;
		else
		{
			count_j=0;
			if (disp == 10)	disp = 0;
			else disp = 10;
		}
	}
}

void blink_disable(void)
{
	disp = 0;
}

